<template>
    <div>
      <index-njt v-if='isShow' :title='title' />
    </div>
</template>

<script>
  import IndexNjt from "@/views/IndexNjt.vue";
  import {getAction} from "@/utils/axiosUtils";


export default {
  name: "Index",
  components: { IndexNjt },
  data() {
    return {
      // 版本号
      version: "3.8.9",
      title:null,
      isShow:false,
      url:{
        index:'/njt/index/hasIndexAuth',
      }
    };
  },
  created() {
      this.initIndex()
    },
  methods: {
    //根据登录用户判断权限,展示不同页面
     initIndex(){
        try {
          let res =  getAction(this.url.index)
          let {code, data: {hasIndex, title}} = res
          if (code === 200) {
            //判断是否加载首页
            if (hasIndex) {
              //设置首页标题
              this.title = title
            } else {
              //判断是否是监管者
              //跳转到合格证打印记录
               this.$router.push('/certificate/certificate')
            }
          }
        } catch (e) {
          console.log("获取首页权限异常",e)
        } finally {
          this.isShow = true
        }
      },
  }
};
</script>

<style scoped lang="scss">

</style>

